<template>
  <div class="Document">
    <div class="content" v-html="item.description"></div>
    <a v-if="url" :href="url" download="下载范本" class="download"><span>下载范本</span></a>
    <!-- <a href="javascript: void(0);" class="download"><span>{{name}}</span></a> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      item: [],
      url: '',
      name: ""
    };
  },
  mounted() {
    this.item = JSON.parse(this.$route.query.item);
    this.setTitle(this.item.title);
    this.download();
    console.log('ddd');
  },
  methods: {
    download(){
      this.$toast.loading({
        message: "加载中...",
        forbidClick: true
      });
      if(!this.slow.documenttest){
        this.post('/document_template/uploadDocument', {
          id: this.item.id
        }).then(r => {
          this.$toast.clear();
          if(r.object){
            let url = this.slow.interport.host + r.object;
            this.url = url;
          }
          this.name = r.message;
          console.log('url', this.url);
          
          // window.open(url);
        });
      }else{
        this.$toast.clear();
        const r = require("@/assets/d.json");
        let url = this.slow.interport.host + r.object;
        this.url = url;
        // window.open(url);
      }
      
    }
  }
};
</script>
<style lang="scss" scoped>
@import "~@/smobile.scss";
.content{
  padding: 15px;
}
.download{
  position: fixed;
  right: 0;
  width: (235px/2);
  height: (80px/2);
  bottom: 80px;
  background-image: url("~@/assets/d.png");
  background-size: cover;
  background-repeat: no-repeat;
  color: #ffffff;
  line-height: (80px/2);
  text-align: right;
  font-size: $sm-font-size-base;
  span{
    margin-right: 15px;
  }
}
</style>